Skip to content

fix(pm-dispatch): validate GitHub API response shapes at the boundary (#7101) - #8088

Merged
dezren39 merged 1 commit into
mainfrom
queue/12768-7101-github-shape-validation
Nov 10, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/12768-7101-github-shape-validation

Conversation

@dezren39

@dezren39 dezren39 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Closes #7101. Queue task 12768 (lane code-w).

Problem

pm-stack/dispatch/src/github.ts shape-trusted every GitHub API response body via bare casts: installation {} minted against /app/installations/undefined/access_tokens, token {} was sent as Bearer undefined, create {} returned a phantom {number: undefined, url: undefined} as success, lookup {} fabricated an issue state (rejected by #3007 attach verification as "is undefined, not open"), and null bodies escaped as raw TypeErrors — the create one then duplicated the tracking issue via the gh fallback.

Fix

  • All four res.json() bodies (installation lookup, access-token mint, issue create, issue lookup — app route and the gh-route parse in getIssue) are validated before use: JSON object body; installation id a positive integer; token a non-empty string with a parseable expires_at; create/lookup number an integer, state/html_url strings.
  • Violations raise GitHubError (new MalformedBodyError subclass) naming the endpoint and the malformed field — never a raw TypeError/SyntaxError, never a coerced/undefined value.
  • A malformed 2xx create body does NOT trigger the gh fallback create (the issue may already exist server-side); it surfaces as an explicit error. Malformed installation/token replies still fall back to gh with the malformed-body reason preserved in the combined error.
  • No behavior change for well-formed responses or definitive HTTP failures (404 lookup still returns null).

Tests (oracle: the #7101 acceptance)

New pm-stack/dispatch/test/github.test.ts, stubbed fetch in the attach_verify.test.ts style; the repo slug is a nonexistent one so the gh fallback fails deterministically and can never create a real issue in any environment.

  • Post-fix: 12/12 pass; full dispatch suite 169/169 pass.
  • Pre-fix (src change stashed): 9 fail — the new tests are real regressions.
  • bunx tsc --noEmit in the bare worktree fails identically on the unpatched tree (missing bun type definitions; no node_modules in the worktree) — pre-existing environment gap, not this change.

Incident note: an early test draft's fake-gh PATH shim was not honored by Bun.spawn, so the real gh fallback created ten fixture issues (#8075–#8084, title "t"); all ten were closed as not planned with an explanation in the same shift, and the test was redesigned (nonexistent slug) so this cannot recur.

…#7101)

Installation id, access-token, issue-create and issue-lookup bodies in pm-stack/dispatch/src/github.ts were shape-trusted via bare casts: a wrong-shape 2xx minted against /installations/undefined, sent Bearer <redacted>, returned a phantom issue as success, fabricated a lookup state, and null bodies escaped as raw TypeErrors (the create one then duplicated the issue via the gh fallback). All four bodies are now validated before use; violations raise GitHubError naming the endpoint and the malformed field. A malformed 2xx create body no longer falls back to a gh create (the issue may already exist server-side); malformed installation/token replies still fall back with the reason preserved. New test/github.test.ts (stubbed fetch, nonexistent repo slug so the gh fallback fails deterministically): 12/12 pass post-fix, 9 fail pre-fix; full dispatch suite 169/169.
@dezren39
dezren39 requested a review from a team as a code owner November 10, 2026 00:49
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-10T00:49:06.800536Z
We couldn’t complete this review. Comment @codex review to try again.
5f42f2f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dezren39

Copy link
Copy Markdown
Member Author

🤖 Agent note · codex-gate disposition

  • Agent: repo queue worker, lane code-w · Task: task 12768
  • Codex code review on commit 5f42f2f did not complete: the review run failed on Codex usage limits ("You have reached your Codex usage limits for code reviews") and produced no findings — there are no inline Codex comments on this PR to disposition.
  • Disposition under the fleet Codex gate: no undispositioned findings exist; merging proceeds on the local verification recorded in the PR body (new tests 12/12 post-fix / 9 fail pre-fix; full dispatch suite 169/169).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant